// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch
{
	public sealed partial class IndicesOptions
	{
		[JsonInclude]
		[JsonPropertyName("allow_no_indices")]
		public bool? AllowNoIndices { get; set; }

		[JsonInclude]
		[JsonPropertyName("expand_wildcards")]
		[JsonConverter(typeof(ExpandWildcardsConverter))]
		public IEnumerable<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcards { get; set; }

		[JsonInclude]
		[JsonPropertyName("ignore_throttled")]
		public bool? IgnoreThrottled { get; set; }

		[JsonInclude]
		[JsonPropertyName("ignore_unavailable")]
		public bool? IgnoreUnavailable { get; set; }
	}

	public sealed partial class IndicesOptionsDescriptor : SerializableDescriptorBase<IndicesOptionsDescriptor>
	{
		internal IndicesOptionsDescriptor(Action<IndicesOptionsDescriptor> configure) => configure.Invoke(this);
		public IndicesOptionsDescriptor() : base()
		{
		}

		private bool? AllowNoIndicesValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcardsValue { get; set; }

		private bool? IgnoreThrottledValue { get; set; }

		private bool? IgnoreUnavailableValue { get; set; }

		public IndicesOptionsDescriptor AllowNoIndices(bool? allowNoIndices = true)
		{
			AllowNoIndicesValue = allowNoIndices;
			return Self;
		}

		public IndicesOptionsDescriptor ExpandWildcards(IEnumerable<Elastic.Clients.Elasticsearch.ExpandWildcard>? expandWildcards)
		{
			ExpandWildcardsValue = expandWildcards;
			return Self;
		}

		public IndicesOptionsDescriptor IgnoreThrottled(bool? ignoreThrottled = true)
		{
			IgnoreThrottledValue = ignoreThrottled;
			return Self;
		}

		public IndicesOptionsDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true)
		{
			IgnoreUnavailableValue = ignoreUnavailable;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AllowNoIndicesValue.HasValue)
			{
				writer.WritePropertyName("allow_no_indices");
				writer.WriteBooleanValue(AllowNoIndicesValue.Value);
			}

			if (ExpandWildcardsValue is not null)
			{
				writer.WritePropertyName("expand_wildcards");
				SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.ExpandWildcard>(ExpandWildcardsValue, writer, options);
			}

			if (IgnoreThrottledValue.HasValue)
			{
				writer.WritePropertyName("ignore_throttled");
				writer.WriteBooleanValue(IgnoreThrottledValue.Value);
			}

			if (IgnoreUnavailableValue.HasValue)
			{
				writer.WritePropertyName("ignore_unavailable");
				writer.WriteBooleanValue(IgnoreUnavailableValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}